<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资产盘点列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>盘点编号：</label>
                                <input type="text" name="checkNo"/>
                            </li>
                            <li>
                                <label>盘点名称：</label>
                                <input type="text" name="checkName"/>
                            </li>
                            <li class="select-time">
                                <label>盘点时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCheckTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCheckTime]"/>
                            </li>
                            <li>
                                <label>盘点状态：</label>
                                <select name="checkStatus" th:with="type=${@dict.getType('check_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>创建人：</label>
                                <input type="text" name="createBy"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="assets:check:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="assets:check:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        function godown(id) {
            $.modal.confirm("确认要完结资产盘点吗?", function() {
                var url = table.options.godownUrl;
                var data = { "ids": id };
                $.operate.submit(url, "post", "json", data);
//            $.modal.close();
            });
        }


        var editFlag = [[${@permission.hasPermi('assets:check:edit')}]];
        var removeFlag = [[${@permission.hasPermi('assets:check:remove')}]];
        var checkStatusDatas = [[${@dict.getType('check_status')}]];
        var checkAssetsTypeDatas = [[${@dict.getType('assets_type')}]];
        var checkAssetsStatusDatas = [[${@dict.getType('assets_status')}]];
        var prefix = ctx + "assets/check";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                godownUrl: prefix + "/godown",
                modalName: "资产盘点",
                sortName: "createTime",                         // 排序列名称
                sortOrder: "desc",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'checkId',
                    title: '',
                    visible: false
                },
                {
                    field: 'checkStatus',
                    title: '状态',
                    align: 'left',
                    formatter: function(value, row, index) {
                        if(value == 1){
                            var actions = [];
                            actions.push('<span class="label label-warning">'+$.table.selectDictLabel(checkStatusDatas, value)+'</span> ');
                            return actions.join('');

                        }else{
                            return $.table.selectDictLabel(checkStatusDatas, value);
                        }

                    }
                },
                {
                    field: 'checkNo',
                    title: '盘点编号'
                },
                {
                    field: 'checkName',
                    title: '盘点名称'
                },
                {
                    field: 'checkTime',
                    title: '盘点时间'
                },
//                {
//                    field: 'checkAssetsType',
//                    title: '资产类别',
//                    formatter: function(value, row, index) {
//                       return $.table.selectDictLabels(checkAssetsTypeDatas, value);
//                    }
//                },
//                {
//                    field: 'checkAssetsStatus',
//                    title: '资产状态',
//                    formatter: function(value, row, index) {
//                       return $.table.selectDictLabels(checkAssetsStatusDatas, value);
//                    }
//                },
//                {
//                    field: 'checkDepts',
//                    title: '所属部门'
//                },
                {
                    field: 'createBy',
                    title: '创建人'
                },
                {
                    field: 'checkTime',
                    title: '盘点时间'
                },
                {
                    field: 'checkNum',
                    title: '盘点资产数量'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.checkStatus != 2) {
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.checkId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.checkId + '\')"><i class="fa fa-remove"></i>删除</a> ');
//                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="godown((\'' + row.checkId + '\'))"><i class="fa fa-hand-paper-o"></i>完结</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.checkId + '\',\'' + row.checkName + '\')""><i class="fa fa-list-alt"></i>盘点</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>